let register = function (event) {
    event.preventDefault();
    console.log("注册");
}
let flag = false;
//电子邮件验证
document.getElementsByClassName("email")[0].onblur = function () {
    let nickNameValue = document.getElementsByClassName("email")[0].value;
    if (!flag) {

        if (nickNameValue == "") {
            document.getElementsByClassName("nick")[0].innerHTML = "邮箱不能为空！";
        }
    } else {
        document.getElementsByClassName("nick")[0].innerHTML = "";
    }
    if (flag == false)
        flag = true;
    else
        flag = false;
}
//邮箱格式验证
document.getElementsByClassName("email")[0].onchange = function() {
    let email = this.value;
    let reg = /^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/;
    if (reg.test(email)) {
        document.getElementsByClassName("nick")[0].innerHTML = "";
    } else {
        document.getElementsByClassName("nick")[0].innerHTML = "邮箱格式错误！";
    }
}
//图片验证码验证
document.getElementsByClassName("verifCode")[0].onblur = function () {
    let nickNameValue = document.getElementsByClassName("verifCode")[0].value;
    if (!flag) {

        if (nickNameValue == "") {
            document.getElementsByClassName("nick")[1].innerHTML = "图片验证码不能为空！";
        }
    } else {
        document.getElementsByClassName("nick")[1].innerHTML = "";
    }
    if (flag == false)
        flag = true;
    else
        flag = false;
}
//邮箱验证码验证
document.getElementsByClassName("mailVerif")[0].onblur = function () {
    let nickNameValue = document.getElementsByClassName("mailVerif")[0].value;
    if (!flag) {
        if (nickNameValue == "") {
            document.getElementsByClassName("nick")[2].innerHTML = "邮箱验证码不能为空！";
        }
    } else {
        document.getElementsByClassName("nick")[2].innerHTML = "";
    }
    if (flag == false)
        flag = true;
    else
        flag = false;
}

//昵称验证
document.getElementsByClassName("name")[0].onblur = function () {
    let nickNameValue = document.getElementsByClassName("name")[0].value;
    if (!flag) {

        if (nickNameValue == "") {
            document.getElementsByClassName("nick")[3].innerHTML = "昵称不能为空！";
        }
    } else {
        document.getElementsByClassName("nick")[3].innerHTML = "";
    }
    if (flag == false)
        flag = true;
    else
        flag = false;
}


document.getElementsByClassName("psd")[0].onblur = function () {
    let nickNameValue = document.getElementsByClassName("psd")[0].value;
    if (!flag) {

        if (nickNameValue == "") {
            document.getElementsByClassName("nick")[5].innerHTML = "密码不能为空！";
            document.getElementsByClassName("nick")[6].innerHTML = "";
            document.getElementsByClassName("nick")[7].innerHTML = "";
        }

    } else {

        document.getElementsByClassName("nick")[5].innerHTML = "";
        document.getElementsByClassName("nick")[6].innerHTML = "";
        document.getElementsByClassName("nick")[7].innerHTML = "";
    }
    if (flag == false)
        flag = true;
    else
        flag = false
}
document.getElementsByClassName("verifCode")[1].onblur = function () {

    let nickNameValue = document.getElementsByClassName("verifCode")[1].value;

    console.log(nickNameValue);
    if (!flag) {

        if (nickNameValue == "") {
            document.getElementsByClassName("nick")[4].innerHTML = "个性域名不能为空！";
        }else  {
            document.getElementsByClassName("nick")[4].innerHTML = "";
        }
    }
    if (flag == false)
        flag = true;
    else
        flag = false
}
document.getElementsByClassName("checkbox")[0].onblur = function () {

    let nickNameValue = document.getElementsByClassName("checkbox")[0].value;

    console.log(nickNameValue);
    if (!flag) {

        if (nickNameValue == "") {
            document.getElementsByClassName("nick")[8].innerHTML = "个性域名不能为空！";
        }else  {
            document.getElementsByClassName("nick")[8].innerHTML = "";
        }
    }
    if (flag == false)
        flag = true;
    else
        flag = false;
}
function reloadCaptcha() {
    let captchImg=document.getElementById("captchImg");
    captchImg.src="/captcha?t="+(new Date()).getTime();
}
$('#sendmail').on('click',function (e) {
    e.preventDefault();
    $.ajax({
        url:"/sendmail",
        method:"POST",
        catche:false
    }).done(function () {

    });
});